<link href="markdown.css" rel="stylesheet">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<h1 id="sdn接口文档">SDN接口文档</h1>
<p>文档版本: <em>v1.0</em><br />接口协议: <em>http</em><br />报文格式: <em>json</em><br />报文编码: <em>utf-8</em><br />正式接口: <em>api.sdn.com</em><br />测试接口: <em>api.sdn.com</em></p>
<h2 id="接口列表">接口列表</h2>
<table>
<thead>
<tr class="header">
<th align="left">接口名</th>
<th align="left">地址</th>
<th align="left">请求类型</th>
<th align="left">完成情况</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><a href="#api1">加入到虚拟域</a></td>
<td align="left">/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server</td>
<td align="left">POST</td>
<td align="left">NO</td>
</tr>
<tr class="even">
<td align="left"><a href="#api2">从虚拟域中删除</a></td>
<td align="left">/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server/{server_id}</td>
<td align="left">DELETE</td>
<td align="left">NO</td>
</tr>
<tr class="odd">
<td align="left"><a href="#api3">查询虚拟域中的虚拟机</a></td>
<td align="left">/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server</td>
<td align="left">GET</td>
<td align="left">NO</td>
</tr>
<tr class="even">
<td align="left"><a href="#api4">设置重定向策略</a></td>
<td align="left">/v1.0/{tenant_id}/devs/{dev_id}/server</td>
<td align="left">POST</td>
<td align="left">NO</td>
</tr>
<tr class="odd">
<td align="left"><a href="#api5">删除重定向策略</a></td>
<td align="left">/v1.0/{tenant_id}/devs/{dev_id}/server/{server_id}</td>
<td align="left">DELETE</td>
<td align="left">NO</td>
</tr>
<tr class="even">
<td align="left"><a href="#api6">查询重定向策略</a></td>
<td align="left">/v1.0/{tenant_id}/devs/{dev_id}/server</td>
<td align="left">GET</td>
<td align="left">NO</td>
</tr>
<tr class="odd">
<td align="left"><a href="#api7">设置访问控制策略</a></td>
<td align="left">/v1.0/{tenant_id}/rules/server/{server_id}</td>
<td align="left">POST</td>
<td align="left">NO</td>
</tr>
<tr class="even">
<td align="left"><a href="#api8">删除访问控制策略</a></td>
<td align="left">/v1.0/{tenant_id}/rules/{type}</td>
<td align="left">DELETE</td>
<td align="left">NO</td>
</tr>
<tr class="odd">
<td align="left"><a href="#api9">查询访问控制策略</a></td>
<td align="left">/v1.0/{tenant_id}/rules/server/{server_id}</td>
<td align="left">GET</td>
<td align="left">NO</td>
</tr>
<tr class="even">
<td align="left"><a href="#api10">设置漏洞扫描服务</a></td>
<td align="left">/v1.0/{tenant_id}/server/{server_id}/action</td>
<td align="left">POST</td>
<td align="left">NO</td>
</tr>
<tr class="odd">
<td align="left"><a href="#api11">获取扫描结果</a></td>
<td align="left">/v1.0/{tenant_id}/vulnerabilitys/server/{server_id}</td>
<td align="left">GET</td>
<td align="left">NO</td>
</tr>
</tbody>
</table>
<h2 id="约定">约定</h2>
<p>1.所有接口，都需要以header方式传递token，以便后台认证。</p>
<h3 id="通用http响应码">通用HTTP响应码</h3>
<table>
<thead>
<tr class="header">
<th align="left">code</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">200</td>
<td align="left">请求成功</td>
</tr>
<tr class="even">
<td align="left">404</td>
<td align="left">资源未发现</td>
</tr>
</tbody>
</table>
<h3 id="接口返回值示例">接口返回值示例</h3>
示例1, 接口访问成功, 服务端带list数据:
<pre>
{
    "virtdomains": [
        {
            "id": "12312312323",
            "name": "lishi"
        },
        {
            "id": "12312312323",
            "name": "zhansan"
        }
    ]
}
</pre>
 
示例2, 服务端返回单条数据:
<pre>
{
    "virtdomain": {
        "id": "12312312323",
        "name": "lishi"
    }
}
</pre>

<h3 id="全局header参数">全局Header参数</h3>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">示例</th>
<th align="left">完成情况</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">X-Auth-Token</td>
<td align="left">00320d40-89f8-4b28-d18e-fe12abefcf47</td>
<td align="left">token值</td>
</tr>
<tr class="even">
<td align="left">Accept</td>
<td align="left">application/json</td>
<td align="left">输入参数格式为json</td>
</tr>
</tbody>
</table>
<h2 id="api1">加入到虚拟域</h2>
<p>地址：/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server<br />提交方式：POST</p>
<h3 id="接口输入">接口输入</h3>
<h4 id="url参数">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">00320d40-89f8-4b28-d18e-fe12abefcf47</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">virtdomain_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left"></td>
<td align="left">The virtual domain id.</td>
</tr>
</tbody>
</table>
<h4 id="body参数">body参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">joinDomain</td>
<td align="left">是</td>
<td align="left">map</td>
<td align="left"></td>
<td align="left">Specify the joinDomain action in the request body.</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">00320e40-89f8-4b28-d1fe-fe12abefcf47</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="接口输出">接口输出</h3>
<h4 id="http响应码">HTTP响应码</h4>
<p>201 请求失败<br />202 虚拟域中已经存在该server<br />203 请求成功</p>
<h4 id="body">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">joinDomain</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left"></td>
<td align="left">Specify the joinDomain action in the request body.</td>
</tr>
<tr class="even">
<td align="left">virtdomain_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left"></td>
<td align="left">The virutal domain id.</td>
</tr>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">3cb9bc59-5699-4588-a4b1-b87f96708bc6</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">ce531f90-199f-48c0-816c-13e38010b442</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="示例">示例：</h3>
<pre>
curl -X POST -H "Accept:application/json" -d '{"joinDomain":{"server_id": "ce531f90-199f-48c0-816c-13e38010b442"}}' http://api.sdn.com/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server | python -m json.tool

{
    "joinDomain": {
        "virtdomain_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc8",
            "tenant_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
            "server_id": "ce531f90-199f-48c0-816c-13e38010b442",
    }
}
</pre>


<h2 id="api2">从虚拟域中删除</h2>
<p>地址：/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server/{server_id}<br />提交方式：DELETE</p>
<h3 id="接口输入-1">接口输入</h3>
<h4 id="url参数-1">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">virtdomain_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">The virtual domain.</td>
</tr>
<tr class="odd">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h4 id="body参数-1">body参数</h4>
<p>无</p>
<h3 id="接口输出-1">接口输出</h3>
<h4 id="http响应码-1">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-1">Body</h4>
<p>无</p>
<h3 id="示例-1">示例：</h3>
<pre>
curl -X DELETE -H "Accept:application/json" http://api.sdn.com/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server/{server_id} | python -m json.tool
</pre>


<h2 id="api3">查询虚拟域中虚拟机</h2>
<p>地址：/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server<br />提交方式：GET</p>
<h3 id="接口输入-2">接口输入</h3>
<h4 id="url参数-2">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">virtdomain_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">The virtual domain.</td>
</tr>
</tbody>
</table>
<h4 id="body参数-2">body参数</h4>
<p>无</p>
<h3 id="接口输出-2">接口输出</h3>
<h4 id="http响应码-2">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-2">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必有</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">virtdomain_vms</td>
<td align="left">是</td>
<td align="left">map</td>
<td align="left"></td>
<td align="left">返回数据</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="示例-2">示例：</h3>
<pre>
curl -X GET -H "Accept:application/json" -d http://api.sdn.com/v1.0/{tenant_id}/virtdomains/{virtdomain_id}/server | python -m json.tool

{
    "virtdomain_servers":
    [
        {
            "server_id":"ce531f90-199f-48c0-816c-13e38010b441"
        },
        {
            "server_id":"ce531f90-199f-48c0-816c-13e38010b442"
        }
    ]
}
</pre>


<h2 id="api4">设置重定向策略</h2>
<p>地址：/v1.0/{tenant_id}/devs/{dev_id}/server<br />提交方式：POST</p>
<h3 id="接口输入-3">接口输入</h3>
<h4 id="url参数-3">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">dev_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">设备ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-3">body参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">setFlowRedirect</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">Specify the setFlowRedirect action in the request body.</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="接口输出-3">接口输出</h3>
<h4 id="http响应码-3">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-3">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">setFlowRedirect</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">Specify the joinDomain action in the request body.</td>
</tr>
<tr class="even">
<td align="left">dev_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">The device id.</td>
</tr>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="示例-3">示例：</h3>
<pre>
curl -X POST -H "Accept:application/json" -d '{"setFlowRedirect":{"server_id": "ce531f90-199f-48c0-816c-13e38010b442"}}' http://api.sdn.com//v1.0/{tenant_id}/devs/{dev_id}/server | python -m json.tool

{
    "setFlowRedirect": {
        "dev_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc8",
        "tenant_id": "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
        "server_id": "ce531f90-199f-48c0-816c-13e38010b442",
    }
}
</pre>


<h2 id="api5">删除重定向策略</h2>
<p>地址：/v1.0/{tenant_id}/devs/{dev_id}/server/{server_id}<br />提交方式：DELETE</p>
<h3 id="接口输入-4">接口输入</h3>
<h4 id="url参数-4">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">dev_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">设备ID</td>
</tr>
<tr class="odd">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h4 id="body参数-4">body参数</h4>
<p>无</p>
<h3 id="接口输出-4">接口输出</h3>
<h4 id="http响应码-4">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-4">Body</h4>
<p>无</p>
<h3 id="示例-4">示例：</h3>
<pre>
curl -X DELETE -H "Accept:application/json" -d http://api.sdn.com/v1.0/{tenant_id}/devs/{dev_id}/server/{server_id} | python -m json.tool
</pre>


<h2 id="api6">查询重定向策略</h2>
<p>地址：/v1.0/{tenant_id}/devs/dev_id/server<br />提交方式：GET</p>
<h3 id="接口输入-5">接口输入</h3>
<h4 id="url参数-5">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The ID for the tenant or account in a multi-tenancy cloud.</td>
</tr>
<tr class="even">
<td align="left">dev_id</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">设备ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-5">body参数</h4>
<p>无</p>
<h3 id="接口输出-5">接口输出</h3>
<h4 id="http响应码-5">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-5">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必有</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">virtdomain_vms</td>
<td align="left">是</td>
<td align="left">map</td>
<td align="left">见示例</td>
<td align="left">返回数据</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">The UUID for the server of interest to you.</td>
</tr>
</tbody>
</table>
<h3 id="示例-5">示例：</h3>
<pre>
curl -X GET -H "Accept:application/json" -d http://api.sdn.com/v1.0/{tenant_id}/devs/dev_id/server | python -m json.tool

{
    "dev_servers":
    [
        {
            "server_id":"ce531f90-199f-48c0-816c-13e38010b441"
        },
        {
            "server_id":"ce531f90-199f-48c0-816c-13e38010b442"
        }
    ]
}
</pre>


<h2 id="api7">设置访问控制策略</h2>
<p>地址：/v1.0/{tenant_id}/rules/server/{server_id}<br />提交方式：POST</p>
<h3 id="接口输入-6">接口输入</h3>
<h4 id="url参数-6">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">租户ID</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">租户ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-6">body参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">适用策略</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">setAcl</td>
<td align="left"></td>
<td align="left">map</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">type</td>
<td align="left"></td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">策略类型（L2</td>
</tr>
<tr class="odd">
<td align="left">ip_src</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机1的ip地址</td>
</tr>
<tr class="even">
<td align="left">ip_dst</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机2的ip地址</td>
</tr>
<tr class="odd">
<td align="left">mac_src</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="even">
<td align="left">mac_dst</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="odd">
<td align="left">ip</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的ip地址</td>
</tr>
<tr class="even">
<td align="left">mac</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的mac地址</td>
</tr>
<tr class="odd">
<td align="left">port</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">用户指定的port</td>
</tr>
</tbody>
</table>
<h3 id="接口输出-6">接口输出</h3>
<h4 id="http响应码-6">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-6">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">适用策略</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">setAcl</td>
<td align="left"></td>
<td align="left">map</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">type</td>
<td align="left"></td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">策略类型（L2</td>
</tr>
<tr class="odd">
<td align="left">ip_src</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机1的ip地址</td>
</tr>
<tr class="even">
<td align="left">ip_dst</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机2的ip地址</td>
</tr>
<tr class="odd">
<td align="left">mac_src</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="even">
<td align="left">mac_dst</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="odd">
<td align="left">ip</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的ip地址</td>
</tr>
<tr class="even">
<td align="left">mac</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的mac地址</td>
</tr>
<tr class="odd">
<td align="left">port</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">用户指定的port</td>
</tr>
</tbody>
</table>
<h3 id="示例-6">示例：</h3>
<pre>
curl -X POST -H "Accept:application/json" -d '{"setAcl":{"type":"L2","mac_src":"xxxxxx","mac_dst":"xxxxxx"}}'  http://api.sdn.com/v1.0/{tenant_id}/rules/server/{server_id} | python -m json.tool

{
    "setAcl":{
        "type": "L2",
        "mac_src": "00:ac:34:35:56:44",
        "mac_dst": "00:ac:34:35:56:65"
    }
}
</pre>


<h2 id="api8">删除访问控制策略</h2>
<p>地址：/v1.0/{tenant_id}/rules/server/{server_id}<br />提交方式：DELETE</p>
<h3 id="接口输入-7">接口输入</h3>
<h4 id="url参数-7">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">租户ID</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">虚拟机ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-7">body参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">适用策略</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">delAcl</td>
<td align="left"></td>
<td align="left">map</td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">type</td>
<td align="left"></td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">策略类型（L2</td>
</tr>
<tr class="odd">
<td align="left">ip_src</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机1的ip地址</td>
</tr>
<tr class="even">
<td align="left">ip_dst</td>
<td align="left">L2</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机2的ip地址</td>
</tr>
<tr class="odd">
<td align="left">mac_src</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="even">
<td align="left">mac_dst</td>
<td align="left">L2</td>
<td align="left">L3</td>
<td align="left">string</td>
<td align="left">见示例</td>
</tr>
<tr class="odd">
<td align="left">ip</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的ip地址</td>
</tr>
<tr class="even">
<td align="left">mac</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">虚拟机的mac地址</td>
</tr>
<tr class="odd">
<td align="left">port</td>
<td align="left">L4</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">用户指定的port</td>
</tr>
</tbody>
</table>
<h3 id="接口输出-7">接口输出</h3>
<h4 id="http响应码-7">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-7">Body</h4>
<p>无</p>
<h3 id="示例-7">示例：</h3>
<pre>
curl -X DELETE -H "Accept:application/json" -d '{"delAcl":{"type":"L2","mac_src":"xxxxxx","mac_dst":"xxxxxx"}}'  http://api.sdn.com/v1.0/{tenant_id}/rules/server/{server_id} | python -m json.tool
</pre>


<h2 id="api9">查询访问控制策略</h2>
<p>地址：/v1.0/{tenant_id}/rules/server/{server_id}<br />提交方式：GET</p>
<h3 id="接口输入-8">接口输入</h3>
<h4 id="url参数-8">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">租户ID</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">虚拟机ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-8">body参数</h4>
<p>无</p>
<h3 id="接口输出-8">接口输出</h3>
<h4 id="http响应码-8">HTTP响应码</h4>
<p>201 请求失败<br />202 安全策略已经存在<br />203 请求成功</p>
<h4 id="body-8">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">L2_mac</td>
<td align="left">否</td>
<td align="left">map</td>
<td align="left">见示例</td>
<td align="left">L2策略</td>
</tr>
<tr class="even">
<td align="left">L3_ip</td>
<td align="left">否</td>
<td align="left">map</td>
<td align="left">见示例</td>
<td align="left">L3策略</td>
</tr>
<tr class="odd">
<td align="left">L4_port</td>
<td align="left">否</td>
<td align="left">map</td>
<td align="left">见示例</td>
<td align="left">L4策略</td>
</tr>
<tr class="even">
<td align="left">vm_ip</td>
<td align="left">否</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">L3策略中的虚拟机ip</td>
</tr>
<tr class="odd">
<td align="left">vm_mac</td>
<td align="left">否</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">L2策略中的虚拟机ip</td>
</tr>
<tr class="even">
<td align="left">vm_port</td>
<td align="left">否</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">L4策略中的虚拟机port</td>
</tr>
</tbody>
</table>
<h3 id="示例-8">示例：</h3>
<pre>
curl -X GET -H "Accept:application/json" -d  http://api.sdn.com/v1.0/{tenant_id}/sdn/rules/l2/vms/{vm_id} | python -m json.tool

body示例
每次返回的结果只能是下面列表当中的一种  
{"L2_mac":[{"vm_ip":"xxxx"},{"vm_ip":"xxxx"}]}
{"L3_ip":[{"vm_mac":"xxxx"},{"vm_mac":"xxxx"}]}
{"L4_port":[{"vm_port":"xxxx"},{"vm_port":"xxxx"}]}
</pre>


<h2 id="api10">设置漏洞扫描</h2>
<p>地址：/v1.0/{tenant_id}/server/{server_id}/action<br />提交方式：POST</p>
<h3 id="接口输入-9">接口输入</h3>
<h4 id="url参数-9">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">见示例</td>
<td align="left">租户ID</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">xxxxxx</td>
<td align="left">虚拟机ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-9">body参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">scan</td>
<td align="left">是</td>
<td align="left">map</td>
<td align="left">见示例</td>
</tr>
<tr class="even">
<td align="left">type</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">vulnerabilitys为漏洞扫描</td>
</tr>
</tbody>
</table>
<h3 id="接口输出-9">接口输出</h3>
<h4 id="http响应码-9">HTTP响应码</h4>
<p>201 请求失败<br />203 请求成功</p>
<h4 id="body-9">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">scan</td>
<td align="left">是</td>
<td align="left">map</td>
<td align="left">见示例</td>
</tr>
<tr class="even">
<td align="left">type</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">见示例</td>
<td align="left">vulnerabilitys为漏洞扫描</td>
</tr>
</tbody>
</table>
<h3 id="示例-9">示例：</h3>
<pre>
curl -X POST -H "Accept:application/json" -d '{"scan":{"type":"vulnerabilitys"}}'  http://api.sdn.com/v1.0/{tenant_id}/server/{server_id}/action| python -m json.tool
{
    "scan":{
        "type":"vulnerabilitys"
    }
}
</pre>


<h2 id="api11">获取扫描结果</h2>
<p>地址：/v1.0/{tenant_id}/vulnerabilitys/server/{server_id}<br />提交方式：GET</p>
<h3 id="接口输入-10">接口输入</h3>
<h4 id="url参数-10">url参数</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必填</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">tenant_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">xxxxxx</td>
<td align="left">租户ID</td>
</tr>
<tr class="even">
<td align="left">server_id</td>
<td align="left">是</td>
<td align="left">uuid</td>
<td align="left">xxxxxx</td>
<td align="left">虚拟机ID</td>
</tr>
</tbody>
</table>
<h4 id="body参数-10">body参数</h4>
<p>无</p>
<h3 id="接口输出-10">接口输出</h3>
<h4 id="http响应码-10">HTTP响应码</h4>
<p>201 请求失败<br />203 请求成功</p>
<h4 id="body-10">Body</h4>
<table>
<thead>
<tr class="header">
<th align="left">参数名</th>
<th align="left">必有</th>
<th align="left">类型</th>
<th align="left">示例</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">result</td>
<td align="left">是</td>
<td align="left">list</td>
<td align="left"></td>
<td align="left">返回数据</td>
</tr>
<tr class="even">
<td align="left">server_ip</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">202.115.36.90</td>
<td align="left">扫描目标虚拟机的IP</td>
</tr>
<tr class="odd">
<td align="left">scan_time</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">2014-07-14 09:54:52</td>
<td align="left">扫描结束时的时间</td>
</tr>
<tr class="even">
<td align="left">service_name</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">ftp</td>
<td align="left">扫描的服务名称</td>
</tr>
<tr class="odd">
<td align="left">description</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">debug:ftp Anonymous login successful!</td>
<td align="left">扫描漏洞的详细描述</td>
</tr>
<tr class="even">
<td align="left">solution</td>
<td align="left">是</td>
<td align="left">string</td>
<td align="left">you need change your username and password。</td>
<td align="left">针对漏洞的解决建议</td>
</tr>
</tbody>
</table>
<h3 id="示例-10">示例：</h3>
<pre>
curl -X POST -H "Accept:application/json"  http://api.sdn.com/v1.0/{tenant_id}/vulnerabilitys/server/{server_id}| python -m json.tool

{
    "result":[
        {
            "server_ip":"192.168.1.14,192.168.2.14",
            "scan_time":"3456",
            "service_name":"http",
            "description":"description",
            "solution":"Unkown"
        },
        {
            "server_ip":"192.168.1.14,192.168.2.14",
            "scan_time":"1452545751",
            "service_name":"ftp",
            "description":"file service",
            "solution":"Unkown"
        }
    ]
}
</pre>


